#pragma once

#include <QtGui/QMainWindow>

#include "GeneratedFiles/ui/ui_ScriptEditWindow.h"
#include "Script.hpp"
#include "DocumentWindow.hpp"
#include "AngelscriptHighlighter.hpp"




namespace Engine
{
	namespace Edit
	{
		class ScriptEditWindow
			: public DocumentWindow
		{
			Q_OBJECT

		public:

			ScriptEditWindow(Script::ptr script, QWidget* parent);
			virtual ~ScriptEditWindow();



			/**
			 * @returns the script this window displays
			 */
			Script::ptr script() const;

			/**
			 * @returns the contents of the script of this window
			 * @warning these might be unsaved contents
			 */
			QString contents() const;

			/**
			 * @returns the ErrorModel
			 */
			ErrorModel::ptr errorModel() const;



			/**
			 * Changes the state of the window.
			 *
			 * When the state is changed to debugging, every view is required to enter
			 * a read-only mode where the user is unable to change anything at all.
			 *
			 * Editing on the other hand is the default mode.
			 */
			virtual void changeState(State::Type state);

		public slots:

			void onTextChanged();
			void save();

		private:

			::Ui::ScriptEditWindow        ui;
			AngelscriptHighlighter::ptr   m_highlighter;
			Script::ptr                   m_script;
		};
		///////////////////////////////////////////////////////////////////////////////////////////
	}
	///////////////////////////////////////////////////////////////////////////////////////////////
}
///////////////////////////////////////////////////////////////////////////////////////////////////
